#ifndef __OBJECT_H__
#define __OBJECT_H__

#define NUMOBJS 4

// object state bit vector
#define FLAG_ON_TEAM_1	0x01
#define FLAG_ON_TEAM_2	0x02
#define BOMBS_ON_TEAM_1	0x04
#define BOMBS_ON_TEAM_2	0x08
#define FLAG_CAPTURED	0x10

// declarations from other files
struct CellStruct;
struct Maze_Struct;

typedef struct ObjectStruct {
  struct CellStruct *cellPtr;
  uint16_t teamNo;
  uint64_t state;
} Object;

// global array of objects
extern Object Objects[NUMOBJS];

// accessors
#define FLAG_BELONGS_TO_TEAM_1(o)  	  (o->state & FLAG_ON_TEAM_1)
#define FLAG_BELONGS_TO_TEAM_2(o)  	  (o->state & FLAG_ON_TEAM_2)
#define BOMBS_BELONGS_TO_TEAM_1(o) 	  (o->state & BOMBS_ON_TEAM_1)
#define BOMBS_BELONGS_TO_TEAM_2(o) 	  (o->state & BOMBS_ON_TEAM_2)
#define IS_FLAG_CAPTURED(o) 		  (o->state & FLAG_CAPTURED)
// mutator
#define OBJECT_TOGGLE_FLAG_CAPTURE(o) (o->state ^= FLAG_CAPTURED)

// function declarations
uint16_t object_init(struct Maze_Struct *m);
uint16_t object_dump();
uint16_t object_toggle_flag_capture(uint16_t teamNo);
uint16_t object_is_flag_captured(uint16_t teamNo);

#endif
